﻿<Window x:Class="AzureStorageExplorer.BlobProperties"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:AzureStorageExplorer"
        Title="Blob Properties" Height="570" Width="1000" ResizeMode="NoResize" 
        WindowStartupLocation="CenterOwner">
    <StackPanel Orientation="Vertical">
        
        <TabControl x:Name="PropertyTabControl" Height="Auto" Padding="12">
            
            <!-- Properties Tab -->
            
            <TabItem x:Name="PropertiesTag" Header="Properties">
                <StackPanel Orientation="Vertical">
                    <TextBlock Margin="0,8,0,8" Text="Properties marked with an asterisk may be modified."/>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="16" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="32" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="16" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <!-- Column 1 -->

                        <TextBlock Grid.Row="0" Grid.Column="0">Blob Type</TextBlock>
                        <TextBox x:Name="PropBlobType" Grid.Row="0" Grid.Column="2" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="2" Grid.Column="0">Cache Control*</TextBlock>
                        <TextBox Grid.Row="2" Grid.Column="2" x:Name="PropCacheControl" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="4" Grid.Column="0">Container</TextBlock>
                        <TextBox Grid.Row="4" Grid.Column="2" x:Name="PropContainer" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="6" Grid.Column="0">Content Disposition*</TextBlock>
                        <TextBox Grid.Row="6" Grid.Column="2" x:Name="PropContentDisposition" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="8" Grid.Column="0">Content Encoding*</TextBlock>
                        <TextBox Grid.Row="8" Grid.Column="2" x:Name="PropContentEncoding" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="10" Grid.Column="0">Content Language*</TextBlock>
                        <TextBox Grid.Row="10" Grid.Column="2" x:Name="PropContentLanguage" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="12" Grid.Column="0">Content MD5*</TextBlock>
                        <TextBox Grid.Row="12" Grid.Column="2" x:Name="PropContentMD5" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="14" Grid.Column="0">Content Type*</TextBlock>
                        <TextBox Grid.Row="14" Grid.Column="2" x:Name="PropContentType" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="16" Grid.Column="0">Copy State</TextBlock>
                        <TextBox Grid.Row="16" Grid.Column="2" x:Name="PropCopyState" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="18" Grid.Column="0">ETag</TextBlock>
                        <TextBox Grid.Row="18" Grid.Column="2" x:Name="PropETag" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="20" Grid.Column="0">Is Snapshot</TextBlock>
                        <TextBox Grid.Row="20" Grid.Column="2" x:Name="PropIsSnapshot" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="22" Grid.Column="0">Lease Duration</TextBlock>
                        <TextBox Grid.Row="22" Grid.Column="2" x:Name="PropLeaseDuration" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="24" Grid.Column="0">Lease State</TextBlock>
                        <TextBox Grid.Row="24" Grid.Column="2" x:Name="PropLeaseState" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="26" Grid.Column="0">Lease Status</TextBlock>
                        <TextBox Grid.Row="26" Grid.Column="2" x:Name="PropLeaseStatus" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <!-- Column 2 -->

                        <TextBlock Grid.Row="0" Grid.Column="4">Last Modified</TextBlock>
                        <TextBox Grid.Row="0" Grid.Column="6" x:Name="PropLastModified" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="2" Grid.Column="4">Length</TextBlock>
                        <TextBox Grid.Row="2" Grid.Column="6" x:Name="PropLength" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="4" Grid.Column="4">Name</TextBlock>
                        <TextBox Grid.Row="4" Grid.Column="6" x:Name="PropName" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="6" Grid.Column="4">Parent</TextBlock>
                        <TextBox Grid.Row="6" Grid.Column="6" x:Name="PropParent" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="8" Grid.RowSpan="3" Grid.Column="4">Snapshot Qualified Storage Uri</TextBlock>
                        <TextBox Grid.Row="8" Grid.RowSpan="3" Grid.Column="6" x:Name="PropSnapshotQualifiedStorageUri" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="12" Grid.RowSpan="3" Grid.Column="4">Snapshot Qualified Uri</TextBlock>
                        <TextBox Grid.Row="12" Grid.RowSpan="3" Grid.Column="6" x:Name="PropSnapshotQualifiedUri" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="16" Grid.Column="4">Snapshot Time</TextBlock>
                        <TextBox Grid.Row="16" Grid.Column="6" x:Name="PropSnapshotTime" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="18" Grid.Column="4">Stream Minimum Read Size In Bytes</TextBlock>
                        <TextBox Grid.Row="18" Grid.Column="6" x:Name="PropStreamMinimumReadSizeInBytes" IsReadOnly="True" Background="LightYellow"></TextBox>
                        
                        <TextBlock Grid.Row="20" Grid.Column="4">StreamWriteSizeInBytes</TextBlock>
                        <TextBox Grid.Row="20" Grid.Column="6" x:Name="PropStreamWriteSizeInBytes" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="22" Grid.RowSpan="3" Grid.Column="4">Storage Uri</TextBlock>
                        <TextBox Grid.Row="22" Grid.RowSpan="3" Grid.Column="6" x:Name="PropStorageUri" IsReadOnly="True" Background="LightYellow"></TextBox>

                        <TextBlock Grid.Row="26" Grid.Column="4">Uri</TextBlock>
                        <TextBox Grid.Row="26" Grid.Column="6" x:Name="PropUri" IsReadOnly="True" Background="LightYellow"></TextBox>
                    </Grid>
                    <StackPanel x:Name="PropertiesButtonPanel" Orientation="Horizontal"  Margin="0,12,0,12">                        
                        <Button x:Name="PropertiesApply" Padding="4" Margin="0,0,8,0" Click="PropertiesApply_Click">Update Properties</Button>
                        <Button x:Name="PropertiesCancel" Padding="4" Margin="0,0,16,0" IsCancel="true" Click="PropertiesCancel_Click">Close</Button>
                        <TextBlock x:Name="Status" />
                    </StackPanel>
                </StackPanel>
            </TabItem>

            <!-- Content Tab (block blobs only) -->
            
            <TabItem x:Name="ContentTab" Header="Content">
                <StackPanel Orientation="Vertical">
                    <StackPanel Margin="8" Orientation="Horizontal">
                        <ComboBox x:Name="ContentViewType" Width="200" Margin="0,0,8,0" Padding="4,4,4,4" SelectionChanged="ContentViewType_SelectionChanged" >
                            <ComboBoxItem IsSelected="True">--- Select a Content View ---</ComboBoxItem>
                            <ComboBoxItem>Image</ComboBoxItem>
                            <ComboBoxItem>Text</ComboBoxItem>
                            <ComboBoxItem>Video</ComboBoxItem>
                            <ComboBoxItem>Web</ComboBoxItem>
                        </ComboBox>
                        <Button x:Name="ViewContent" Padding="4" Margin="0,0,8,0" Visibility="Hidden" Click="ViewContent_Click">
                            <TextBlock x:Name="ViewContentCaption" Padding="8,0,8,0">View</TextBlock>
                        </Button>
                        <TextBlock Margin="16,8,0,0" Text="Select a content viewer to view or edit the content of this blob."/>
                    </StackPanel>
                    <Grid Width="Auto" Height="400" MaxHeight="400">
                        <Image x:Name="ImageContent" Margin="0,2,0,0" 
                               Height="Auto" MaxHeight="400" Width="Auto" MaxWidth="1000" 
                               VerticalAlignment="Top" HorizontalAlignment="Center" 
                               Visibility="Collapsed" Stretch="Uniform" />
                        <TextBox x:Name="TextContent" Background="LightYellow" Margin="0,2,0,0" Height="400" Visibility="Collapsed"
                                 TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" />
                        <MediaElement x:Name="VideoContent" Width="Auto" Height="400" MaxWidth="1000" 
                                      VerticalAlignment="Top" HorizontalAlignment="Center" 
                                      LoadedBehavior="Play" UnloadedBehavior="Manual" 
                                      Visibility="Collapsed"></MediaElement>
                        <WebBrowser x:Name="WebContent" Width="Auto" Height="400" MaxWidth="1000" />
                    </Grid>
                    <StackPanel x:Name="ContentButtonPanel" Orientation="Horizontal"  Margin="0,12,0,8" Visibility="Hidden">
                        <Button x:Name="ContentSave" Padding="4" Margin="0,0,8,0" Click="ContentSave_Click">Save Content</Button>
                        <Button x:Name="ContentCancel" Padding="4" IsCancel="true" Click="PropertiesCancel_Click">Close</Button>
                    </StackPanel>
                </StackPanel>
            </TabItem>

            <!-- Pages Tab (page blobs only) -->
            
            <TabItem x:Name="PagesTab" Header="Pages" Visibility="Collapsed">
                <StackPanel Orientation="Vertical">
                    <TextBlock Margin="0,8,0,8" Text="You can read or write pages."/>
                    <Grid Height="400">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="8" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="300" />
                            <ColumnDefinition Width="24" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="12" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <ListBox x:Name="PageRanges" Grid.Row="0" Grid.RowSpan="3" Grid.Column="0" Height="384" 
                                 VerticalAlignment="Top" SelectionChanged="PageRanges_SelectionChanged" />

                        <TextBlock Grid.Row="0" Grid.Column="2">Page Number:</TextBlock>

                        <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="4">
                            <TextBox x:Name="PageNumber" Width="40" Background="LightYellow" Margin="0,0,8,0">0</TextBox>
                            <Button x:Name="PagePrev" Padding="4,1,4,1" Margin="0,0,8,0" Click="PagePrev_Click">◀ Prev</Button>
                            <Button x:Name="PageRead" Padding="4" Margin="0,0,8,0" Click="PageRead_Click">Read Page</Button>
                            <Button x:Name="PageNext" Padding="4,1,4,1" Margin="0,0,16,0" Click="PageNext_Click">▶ Next</Button>
                            <Button x:Name="PageWrite" Padding="4" Click="PageWrite_Click">Write Page</Button>
                        </StackPanel>

                        <TextBlock Grid.Row="2" Grid.Column="2" >Hex bytes:</TextBlock>
                        <TextBox Grid.Row="2" Grid.Column="4" x:Name="PageHexData" FontFamily="Consolas" Width="360" Height="340" Background="LightYellow"
                                 TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible"></TextBox>
                    </Grid>
                    <StackPanel x:Name="PagesButtonPanel" Orientation="Horizontal"  Margin="0,12,0,8">
                        <Button x:Name="PagesCancel" Padding="4" IsCancel="true" Click="PropertiesCancel_Click">Close</Button>
                    </StackPanel>
                </StackPanel>
            </TabItem>
        </TabControl>
    </StackPanel>
</Window>
